--DO NOT MODIFY THIS FILE. IT IS ALWAYS OVERWRITTEN ON GENERATION.
--Data Schema For Version 0.0.0.0
--Generated on 2010-02-07 20:29:39

--CREATE TABLE [Categories]
if not exists(select * from sysobjects where name = 'Categories' and xtype = 'U')
CREATE TABLE [dbo].[Categories] (
[CategoryID] [Int] IDENTITY (1, 1) NOT NULL ,
[CategoryName] [NVarChar] (15) NOT NULL ,
[Description] [NText] NULL ,
[Picture] [Image] NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__CATEGORIES_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__CATEGORIES_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [CustomerCustomerDemo]
if not exists(select * from sysobjects where name = 'CustomerCustomerDemo' and xtype = 'U')
CREATE TABLE [dbo].[CustomerCustomerDemo] (
[CustomerID] [NChar] (5) NOT NULL ,
[CustomerTypeID] [NChar] (10) NOT NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__CUSTOMERCUSTOMERDEMO_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__CUSTOMERCUSTOMERDEMO_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [CustomerDemographics]
if not exists(select * from sysobjects where name = 'CustomerDemographics' and xtype = 'U')
CREATE TABLE [dbo].[CustomerDemographics] (
[CustomerDesc] [NText] NULL ,
[CustomerTypeID] [NChar] (10) NOT NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__CUSTOMERDEMOGRAPHICS_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__CUSTOMERDEMOGRAPHICS_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Customers]
if not exists(select * from sysobjects where name = 'Customers' and xtype = 'U')
CREATE TABLE [dbo].[Customers] (
[Address] [NVarChar] (60) NULL ,
[City] [NVarChar] (15) NULL ,
[CompanyName] [NVarChar] (40) NOT NULL ,
[ContactName] [NVarChar] (30) NULL ,
[ContactTitle] [NVarChar] (30) NULL ,
[Country] [NVarChar] (15) NULL ,
[CustomerID] [NChar] (5) NOT NULL ,
[Fax] [NVarChar] (24) NULL ,
[Phone] [NVarChar] (24) NULL ,
[PostalCode] [NVarChar] (10) NULL ,
[Region] [NVarChar] (15) NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__CUSTOMERS_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__CUSTOMERS_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Employees]
if not exists(select * from sysobjects where name = 'Employees' and xtype = 'U')
CREATE TABLE [dbo].[Employees] (
[Address] [NVarChar] (60) NULL ,
[BirthDate] [DateTime] NULL ,
[City] [NVarChar] (15) NULL ,
[Country] [NVarChar] (15) NULL ,
[EmployeeID] [Int] IDENTITY (1, 1) NOT NULL ,
[Extension] [NVarChar] (4) NULL ,
[FirstName] [NVarChar] (10) NOT NULL ,
[HireDate] [DateTime] NULL ,
[HomePhone] [NVarChar] (24) NULL ,
[LastName] [NVarChar] (20) NOT NULL ,
[Notes] [NText] NULL ,
[Photo] [Image] NULL ,
[PhotoPath] [NVarChar] (255) NULL ,
[PostalCode] [NVarChar] (10) NULL ,
[Region] [NVarChar] (15) NULL ,
[ReportsTo] [Int] NULL ,
[Title] [NVarChar] (30) NULL ,
[TitleOfCourtesy] [NVarChar] (25) NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__EMPLOYEES_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__EMPLOYEES_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [EmployeeTerritories]
if not exists(select * from sysobjects where name = 'EmployeeTerritories' and xtype = 'U')
CREATE TABLE [dbo].[EmployeeTerritories] (
[EmployeeID] [Int] NOT NULL ,
[TerritoryID] [NVarChar] (20) NOT NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__EMPLOYEETERRITORIES_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__EMPLOYEETERRITORIES_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Order Details]
if not exists(select * from sysobjects where name = 'Order Details' and xtype = 'U')
CREATE TABLE [dbo].[Order Details] (
[Discount] [Real] NOT NULL  CONSTRAINT [DF__ORDER DETAILS_DISCOUNT] DEFAULT (0),
[OrderID] [Int] NOT NULL ,
[ProductID] [Int] NOT NULL ,
[Quantity] [SmallInt] NOT NULL  CONSTRAINT [DF__ORDER DETAILS_QUANTITY] DEFAULT (1),
[UnitPrice] [Money] NOT NULL  CONSTRAINT [DF__ORDER DETAILS_UNITPRICE] DEFAULT (0),
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__ORDER DETAILS_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__ORDER DETAILS_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Orders]
if not exists(select * from sysobjects where name = 'Orders' and xtype = 'U')
CREATE TABLE [dbo].[Orders] (
[CustomerID] [NChar] (5) NULL ,
[EmployeeID] [Int] NULL ,
[Freight] [Money] NULL  CONSTRAINT [DF__ORDERS_FREIGHT] DEFAULT (0),
[OrderDate] [DateTime] NULL ,
[OrderID] [Int] IDENTITY (1, 1) NOT NULL ,
[RequiredDate] [DateTime] NULL ,
[ShipAddress] [NVarChar] (60) NULL ,
[ShipCity] [NVarChar] (15) NULL ,
[ShipCountry] [NVarChar] (15) NULL ,
[ShipName] [NVarChar] (40) NULL ,
[ShippedDate] [DateTime] NULL ,
[ShipPostalCode] [NVarChar] (10) NULL ,
[ShipRegion] [NVarChar] (15) NULL ,
[ShipVia] [Int] NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__ORDERS_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__ORDERS_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Products]
if not exists(select * from sysobjects where name = 'Products' and xtype = 'U')
CREATE TABLE [dbo].[Products] (
[CategoryID] [Int] NULL ,
[Discontinued] [Bit] NOT NULL  CONSTRAINT [DF__PRODUCTS_DISCONTINUED] DEFAULT (0),
[ProductID] [Int] IDENTITY (1, 1) NOT NULL ,
[ProductName] [NVarChar] (40) NOT NULL ,
[QuantityPerUnit] [NVarChar] (20) NULL ,
[ReorderLevel] [SmallInt] NULL  CONSTRAINT [DF__PRODUCTS_REORDERLEVEL] DEFAULT (0),
[SupplierID] [Int] NULL ,
[UnitPrice] [Money] NULL  CONSTRAINT [DF__PRODUCTS_UNITPRICE] DEFAULT (0),
[UnitsInStock] [SmallInt] NULL  CONSTRAINT [DF__PRODUCTS_UNITSINSTOCK] DEFAULT (0),
[UnitsOnOrder] [SmallInt] NULL  CONSTRAINT [DF__PRODUCTS_UNITSONORDER] DEFAULT (0),
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__PRODUCTS_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__PRODUCTS_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Region]
if not exists(select * from sysobjects where name = 'Region' and xtype = 'U')
CREATE TABLE [dbo].[Region] (
[RegionDescription] [NChar] (50) NOT NULL ,
[RegionID] [Int] NOT NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__REGION_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__REGION_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Shippers]
if not exists(select * from sysobjects where name = 'Shippers' and xtype = 'U')
CREATE TABLE [dbo].[Shippers] (
[CompanyName] [NVarChar] (40) NOT NULL ,
[Phone] [NVarChar] (24) NULL ,
[ShipperID] [Int] IDENTITY (1, 1) NOT NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__SHIPPERS_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__SHIPPERS_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Suppliers]
if not exists(select * from sysobjects where name = 'Suppliers' and xtype = 'U')
CREATE TABLE [dbo].[Suppliers] (
[Address] [NVarChar] (60) NULL ,
[City] [NVarChar] (15) NULL ,
[CompanyName] [NVarChar] (40) NOT NULL ,
[ContactName] [NVarChar] (30) NULL ,
[ContactTitle] [NVarChar] (30) NULL ,
[Country] [NVarChar] (15) NULL ,
[Fax] [NVarChar] (24) NULL ,
[HomePage] [NText] NULL ,
[Phone] [NVarChar] (24) NULL ,
[PostalCode] [NVarChar] (10) NULL ,
[Region] [NVarChar] (15) NULL ,
[SupplierID] [Int] IDENTITY (1, 1) NOT NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__SUPPLIERS_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__SUPPLIERS_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--CREATE TABLE [Territories]
if not exists(select * from sysobjects where name = 'Territories' and xtype = 'U')
CREATE TABLE [dbo].[Territories] (
[RegionID] [Int] NOT NULL ,
[TerritoryDescription] [NChar] (50) NOT NULL ,
[TerritoryID] [NVarChar] (20) NOT NULL ,
[modified_by] [varchar] (50) NULL ,
[modified_date] [datetime] CONSTRAINT [DF__TERRITORIES_MODIFIED_DATE] DEFAULT GetDate() NULL ,
[created_by] [varchar] (50) NULL ,
[created_date] [datetime] CONSTRAINT [DF__TERRITORIES_CREATED_DATE] DEFAULT GetDate() NULL ,
[time_stamp] [timestamp] NOT NULL 
) ON [PRIMARY]


GO

--APPEND AUDIT TRAIL CREATE for Table [Categories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Categories')
ALTER TABLE [Categories] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Categories')
ALTER TABLE [Categories] ADD [created_date] [datetime] CONSTRAINT [DF__CATEGORIES_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Categories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Categories')
ALTER TABLE [Categories] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Categories')
ALTER TABLE [Categories] ADD [modified_date] [datetime] CONSTRAINT [DF__CATEGORIES_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Categories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Categories')
ALTER TABLE [Categories] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [CustomerCustomerDemo]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'CustomerCustomerDemo')
ALTER TABLE [CustomerCustomerDemo] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'CustomerCustomerDemo')
ALTER TABLE [CustomerCustomerDemo] ADD [created_date] [datetime] CONSTRAINT [DF__CUSTOMERCUSTOMERDEMO_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [CustomerCustomerDemo]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'CustomerCustomerDemo')
ALTER TABLE [CustomerCustomerDemo] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'CustomerCustomerDemo')
ALTER TABLE [CustomerCustomerDemo] ADD [modified_date] [datetime] CONSTRAINT [DF__CUSTOMERCUSTOMERDEMO_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [CustomerCustomerDemo]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'CustomerCustomerDemo')
ALTER TABLE [CustomerCustomerDemo] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [CustomerDemographics]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'CustomerDemographics')
ALTER TABLE [CustomerDemographics] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'CustomerDemographics')
ALTER TABLE [CustomerDemographics] ADD [created_date] [datetime] CONSTRAINT [DF__CUSTOMERDEMOGRAPHICS_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [CustomerDemographics]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'CustomerDemographics')
ALTER TABLE [CustomerDemographics] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'CustomerDemographics')
ALTER TABLE [CustomerDemographics] ADD [modified_date] [datetime] CONSTRAINT [DF__CUSTOMERDEMOGRAPHICS_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [CustomerDemographics]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'CustomerDemographics')
ALTER TABLE [CustomerDemographics] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Customers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Customers')
ALTER TABLE [Customers] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Customers')
ALTER TABLE [Customers] ADD [created_date] [datetime] CONSTRAINT [DF__CUSTOMERS_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Customers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Customers')
ALTER TABLE [Customers] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Customers')
ALTER TABLE [Customers] ADD [modified_date] [datetime] CONSTRAINT [DF__CUSTOMERS_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Customers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Customers')
ALTER TABLE [Customers] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Employees]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Employees')
ALTER TABLE [Employees] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Employees')
ALTER TABLE [Employees] ADD [created_date] [datetime] CONSTRAINT [DF__EMPLOYEES_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Employees]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Employees')
ALTER TABLE [Employees] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Employees')
ALTER TABLE [Employees] ADD [modified_date] [datetime] CONSTRAINT [DF__EMPLOYEES_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Employees]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Employees')
ALTER TABLE [Employees] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [EmployeeTerritories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'EmployeeTerritories')
ALTER TABLE [EmployeeTerritories] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'EmployeeTerritories')
ALTER TABLE [EmployeeTerritories] ADD [created_date] [datetime] CONSTRAINT [DF__EMPLOYEETERRITORIES_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [EmployeeTerritories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'EmployeeTerritories')
ALTER TABLE [EmployeeTerritories] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'EmployeeTerritories')
ALTER TABLE [EmployeeTerritories] ADD [modified_date] [datetime] CONSTRAINT [DF__EMPLOYEETERRITORIES_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [EmployeeTerritories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'EmployeeTerritories')
ALTER TABLE [EmployeeTerritories] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Order Details]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Order Details')
ALTER TABLE [Order Details] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Order Details')
ALTER TABLE [Order Details] ADD [created_date] [datetime] CONSTRAINT [DF__ORDER DETAILS_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Order Details]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Order Details')
ALTER TABLE [Order Details] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Order Details')
ALTER TABLE [Order Details] ADD [modified_date] [datetime] CONSTRAINT [DF__ORDER DETAILS_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Order Details]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Order Details')
ALTER TABLE [Order Details] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Orders]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Orders')
ALTER TABLE [Orders] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Orders')
ALTER TABLE [Orders] ADD [created_date] [datetime] CONSTRAINT [DF__ORDERS_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Orders]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Orders')
ALTER TABLE [Orders] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Orders')
ALTER TABLE [Orders] ADD [modified_date] [datetime] CONSTRAINT [DF__ORDERS_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Orders]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Orders')
ALTER TABLE [Orders] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Products]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Products')
ALTER TABLE [Products] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Products')
ALTER TABLE [Products] ADD [created_date] [datetime] CONSTRAINT [DF__PRODUCTS_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Products]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Products')
ALTER TABLE [Products] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Products')
ALTER TABLE [Products] ADD [modified_date] [datetime] CONSTRAINT [DF__PRODUCTS_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Products]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Products')
ALTER TABLE [Products] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Region]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Region')
ALTER TABLE [Region] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Region')
ALTER TABLE [Region] ADD [created_date] [datetime] CONSTRAINT [DF__REGION_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Region]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Region')
ALTER TABLE [Region] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Region')
ALTER TABLE [Region] ADD [modified_date] [datetime] CONSTRAINT [DF__REGION_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Region]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Region')
ALTER TABLE [Region] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Shippers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Shippers')
ALTER TABLE [Shippers] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Shippers')
ALTER TABLE [Shippers] ADD [created_date] [datetime] CONSTRAINT [DF__SHIPPERS_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Shippers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Shippers')
ALTER TABLE [Shippers] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Shippers')
ALTER TABLE [Shippers] ADD [modified_date] [datetime] CONSTRAINT [DF__SHIPPERS_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Shippers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Shippers')
ALTER TABLE [Shippers] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Suppliers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Suppliers')
ALTER TABLE [Suppliers] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Suppliers')
ALTER TABLE [Suppliers] ADD [created_date] [datetime] CONSTRAINT [DF__SUPPLIERS_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Suppliers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Suppliers')
ALTER TABLE [Suppliers] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Suppliers')
ALTER TABLE [Suppliers] ADD [modified_date] [datetime] CONSTRAINT [DF__SUPPLIERS_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Suppliers]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Suppliers')
ALTER TABLE [Suppliers] ADD [time_stamp] [timestamp] NOT NULL

--APPEND AUDIT TRAIL CREATE for Table [Territories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_by' and o.name = 'Territories')
ALTER TABLE [Territories] ADD [created_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'created_date' and o.name = 'Territories')
ALTER TABLE [Territories] ADD [created_date] [datetime] CONSTRAINT [DF__TERRITORIES_CREATED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL MODIFY for Table [Territories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_by' and o.name = 'Territories')
ALTER TABLE [Territories] ADD [modified_by] [varchar] (50) NULL
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'modified_date' and o.name = 'Territories')
ALTER TABLE [Territories] ADD [modified_date] [datetime] CONSTRAINT [DF__TERRITORIES_MODIFIED_DATE] DEFAULT GetDate() NULL

--APPEND AUDIT TRAIL TIMESTAMP for Table [Territories]
if not exists (select * from syscolumns c inner join sysobjects o on c.id = o.id where c.name = 'time_stamp' and o.name = 'Territories')
ALTER TABLE [Territories] ADD [time_stamp] [timestamp] NOT NULL

--PRIMARY KEY FOR TABLE [Categories]
if not exists(select * from sysobjects where name = 'PK_CATEGORIES' and xtype = 'PK')
ALTER TABLE [dbo].[Categories] WITH NOCHECK ADD 
CONSTRAINT [PK_CATEGORIES] PRIMARY KEY CLUSTERED 
(
	[CategoryID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [CustomerCustomerDemo]
if not exists(select * from sysobjects where name = 'PK_CUSTOMERCUSTOMERDEMO' and xtype = 'PK')
ALTER TABLE [dbo].[CustomerCustomerDemo] WITH NOCHECK ADD 
CONSTRAINT [PK_CUSTOMERCUSTOMERDEMO] PRIMARY KEY CLUSTERED 
(
	[CustomerID],
	[CustomerTypeID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [CustomerDemographics]
if not exists(select * from sysobjects where name = 'PK_CUSTOMERDEMOGRAPHICS' and xtype = 'PK')
ALTER TABLE [dbo].[CustomerDemographics] WITH NOCHECK ADD 
CONSTRAINT [PK_CUSTOMERDEMOGRAPHICS] PRIMARY KEY CLUSTERED 
(
	[CustomerTypeID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Customers]
if not exists(select * from sysobjects where name = 'PK_CUSTOMERS' and xtype = 'PK')
ALTER TABLE [dbo].[Customers] WITH NOCHECK ADD 
CONSTRAINT [PK_CUSTOMERS] PRIMARY KEY CLUSTERED 
(
	[CustomerID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Employees]
if not exists(select * from sysobjects where name = 'PK_EMPLOYEES' and xtype = 'PK')
ALTER TABLE [dbo].[Employees] WITH NOCHECK ADD 
CONSTRAINT [PK_EMPLOYEES] PRIMARY KEY CLUSTERED 
(
	[EmployeeID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [EmployeeTerritories]
if not exists(select * from sysobjects where name = 'PK_EMPLOYEETERRITORIES' and xtype = 'PK')
ALTER TABLE [dbo].[EmployeeTerritories] WITH NOCHECK ADD 
CONSTRAINT [PK_EMPLOYEETERRITORIES] PRIMARY KEY CLUSTERED 
(
	[EmployeeID],
	[TerritoryID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Order Details]
if not exists(select * from sysobjects where name = 'PK_ORDER DETAILS' and xtype = 'PK')
ALTER TABLE [dbo].[Order Details] WITH NOCHECK ADD 
CONSTRAINT [PK_ORDER DETAILS] PRIMARY KEY CLUSTERED 
(
	[OrderID],
	[ProductID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Orders]
if not exists(select * from sysobjects where name = 'PK_ORDERS' and xtype = 'PK')
ALTER TABLE [dbo].[Orders] WITH NOCHECK ADD 
CONSTRAINT [PK_ORDERS] PRIMARY KEY CLUSTERED 
(
	[OrderID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Products]
if not exists(select * from sysobjects where name = 'PK_PRODUCTS' and xtype = 'PK')
ALTER TABLE [dbo].[Products] WITH NOCHECK ADD 
CONSTRAINT [PK_PRODUCTS] PRIMARY KEY CLUSTERED 
(
	[ProductID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Region]
if not exists(select * from sysobjects where name = 'PK_REGION' and xtype = 'PK')
ALTER TABLE [dbo].[Region] WITH NOCHECK ADD 
CONSTRAINT [PK_REGION] PRIMARY KEY CLUSTERED 
(
	[RegionID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Shippers]
if not exists(select * from sysobjects where name = 'PK_SHIPPERS' and xtype = 'PK')
ALTER TABLE [dbo].[Shippers] WITH NOCHECK ADD 
CONSTRAINT [PK_SHIPPERS] PRIMARY KEY CLUSTERED 
(
	[ShipperID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Suppliers]
if not exists(select * from sysobjects where name = 'PK_SUPPLIERS' and xtype = 'PK')
ALTER TABLE [dbo].[Suppliers] WITH NOCHECK ADD 
CONSTRAINT [PK_SUPPLIERS] PRIMARY KEY CLUSTERED 
(
	[SupplierID]
) ON [PRIMARY] 
GO

--PRIMARY KEY FOR TABLE [Territories]
if not exists(select * from sysobjects where name = 'PK_TERRITORIES' and xtype = 'PK')
ALTER TABLE [dbo].[Territories] WITH NOCHECK ADD 
CONSTRAINT [PK_TERRITORIES] PRIMARY KEY CLUSTERED 
(
	[TerritoryID]
) ON [PRIMARY] 
GO

--FOREIGN KEY RELATIONSHIP [CustomerDemographics] -> [CustomerCustomerDemo] ([CustomerDemographics].[CustomerTypeID] -> [CustomerCustomerDemo].[CustomerTypeID])
if not exists(select * from sysobjects where name = 'FK__CUSTOMERCUSTOMERDEMO_CUSTOMERDEMOGRAPHICS' and xtype = 'F')
ALTER TABLE [dbo].[CustomerCustomerDemo] ADD 
CONSTRAINT [FK__CUSTOMERCUSTOMERDEMO_CUSTOMERDEMOGRAPHICS] FOREIGN KEY 
(
		[CustomerTypeID]
) REFERENCES [dbo].[CustomerDemographics] (
		[CustomerTypeID]
)
GO

--FOREIGN KEY RELATIONSHIP [Customers] -> [CustomerCustomerDemo] ([Customers].[CustomerID] -> [CustomerCustomerDemo].[CustomerID])
if not exists(select * from sysobjects where name = 'FK__CUSTOMERCUSTOMERDEMO_CUSTOMERS' and xtype = 'F')
ALTER TABLE [dbo].[CustomerCustomerDemo] ADD 
CONSTRAINT [FK__CUSTOMERCUSTOMERDEMO_CUSTOMERS] FOREIGN KEY 
(
		[CustomerID]
) REFERENCES [dbo].[Customers] (
		[CustomerID]
)
GO


--FOREIGN KEY RELATIONSHIP [Employees] -> [Employees] ([Employees].[EmployeeID] -> [Employees].[ReportsTo])
if not exists(select * from sysobjects where name = 'FK__EMPLOYEES_EMPLOYEES' and xtype = 'F')
ALTER TABLE [dbo].[Employees] ADD 
CONSTRAINT [FK__EMPLOYEES_EMPLOYEES] FOREIGN KEY 
(
		[ReportsTo]
) REFERENCES [dbo].[Employees] (
		[EmployeeID]
)
GO


--FOREIGN KEY RELATIONSHIP [Employees] -> [EmployeeTerritories] ([Employees].[EmployeeID] -> [EmployeeTerritories].[EmployeeID])
if not exists(select * from sysobjects where name = 'FK__EMPLOYEETERRITORIES_EMPLOYEES' and xtype = 'F')
ALTER TABLE [dbo].[EmployeeTerritories] ADD 
CONSTRAINT [FK__EMPLOYEETERRITORIES_EMPLOYEES] FOREIGN KEY 
(
		[EmployeeID]
) REFERENCES [dbo].[Employees] (
		[EmployeeID]
)
GO

--FOREIGN KEY RELATIONSHIP [Territories] -> [EmployeeTerritories] ([Territories].[TerritoryID] -> [EmployeeTerritories].[TerritoryID])
if not exists(select * from sysobjects where name = 'FK__EMPLOYEETERRITORIES_TERRITORIES' and xtype = 'F')
ALTER TABLE [dbo].[EmployeeTerritories] ADD 
CONSTRAINT [FK__EMPLOYEETERRITORIES_TERRITORIES] FOREIGN KEY 
(
		[TerritoryID]
) REFERENCES [dbo].[Territories] (
		[TerritoryID]
)
GO


--FOREIGN KEY RELATIONSHIP [Orders] -> [Order Details] ([Orders].[OrderID] -> [Order Details].[OrderID])
if not exists(select * from sysobjects where name = 'FK__ORDER DETAILS_ORDERS' and xtype = 'F')
ALTER TABLE [dbo].[Order Details] ADD 
CONSTRAINT [FK__ORDER DETAILS_ORDERS] FOREIGN KEY 
(
		[OrderID]
) REFERENCES [dbo].[Orders] (
		[OrderID]
)
GO

--FOREIGN KEY RELATIONSHIP [Products] -> [Order Details] ([Products].[ProductID] -> [Order Details].[ProductID])
if not exists(select * from sysobjects where name = 'FK__ORDER DETAILS_PRODUCTS' and xtype = 'F')
ALTER TABLE [dbo].[Order Details] ADD 
CONSTRAINT [FK__ORDER DETAILS_PRODUCTS] FOREIGN KEY 
(
		[ProductID]
) REFERENCES [dbo].[Products] (
		[ProductID]
)
GO


--FOREIGN KEY RELATIONSHIP [Customers] -> [Orders] ([Customers].[CustomerID] -> [Orders].[CustomerID])
if not exists(select * from sysobjects where name = 'FK__ORDERS_CUSTOMERS' and xtype = 'F')
ALTER TABLE [dbo].[Orders] ADD 
CONSTRAINT [FK__ORDERS_CUSTOMERS] FOREIGN KEY 
(
		[CustomerID]
) REFERENCES [dbo].[Customers] (
		[CustomerID]
)
GO

--FOREIGN KEY RELATIONSHIP [Employees] -> [Orders] ([Employees].[EmployeeID] -> [Orders].[EmployeeID])
if not exists(select * from sysobjects where name = 'FK__ORDERS_EMPLOYEES' and xtype = 'F')
ALTER TABLE [dbo].[Orders] ADD 
CONSTRAINT [FK__ORDERS_EMPLOYEES] FOREIGN KEY 
(
		[EmployeeID]
) REFERENCES [dbo].[Employees] (
		[EmployeeID]
)
GO

--FOREIGN KEY RELATIONSHIP [Shippers] -> [Orders] ([Shippers].[ShipperID] -> [Orders].[ShipVia])
if not exists(select * from sysobjects where name = 'FK__ORDERS_SHIPPERS' and xtype = 'F')
ALTER TABLE [dbo].[Orders] ADD 
CONSTRAINT [FK__ORDERS_SHIPPERS] FOREIGN KEY 
(
		[ShipVia]
) REFERENCES [dbo].[Shippers] (
		[ShipperID]
)
GO


--FOREIGN KEY RELATIONSHIP [Categories] -> [Products] ([Categories].[CategoryID] -> [Products].[CategoryID])
if not exists(select * from sysobjects where name = 'FK__PRODUCTS_CATEGORIES' and xtype = 'F')
ALTER TABLE [dbo].[Products] ADD 
CONSTRAINT [FK__PRODUCTS_CATEGORIES] FOREIGN KEY 
(
		[CategoryID]
) REFERENCES [dbo].[Categories] (
		[CategoryID]
)
GO

--FOREIGN KEY RELATIONSHIP [Suppliers] -> [Products] ([Suppliers].[SupplierID] -> [Products].[SupplierID])
if not exists(select * from sysobjects where name = 'FK__PRODUCTS_SUPPLIERS' and xtype = 'F')
ALTER TABLE [dbo].[Products] ADD 
CONSTRAINT [FK__PRODUCTS_SUPPLIERS] FOREIGN KEY 
(
		[SupplierID]
) REFERENCES [dbo].[Suppliers] (
		[SupplierID]
)
GO


--FOREIGN KEY RELATIONSHIP [Region] -> [Territories] ([Region].[RegionID] -> [Territories].[RegionID])
if not exists(select * from sysobjects where name = 'FK__TERRITORIES_REGION' and xtype = 'F')
ALTER TABLE [dbo].[Territories] ADD 
CONSTRAINT [FK__TERRITORIES_REGION] FOREIGN KEY 
(
		[RegionID]
) REFERENCES [dbo].[Region] (
		[RegionID]
)
GO


--INDEX FOR TABLE [Customers] COLUMN [City]
if not exists(select * from sysindexes where name = 'IDX_CUSTOMERS_CITY')
CREATE INDEX [IDX_CUSTOMERS_CITY] ON [dbo].[Customers]([City]) ON [PRIMARY]
GO

--DEFAULTS FOR TABLE [Order Details]
if not exists(select * from sysobjects where name = 'DF__ORDER DETAILS_DISCOUNT' and xtype = 'D')
ALTER TABLE [Order Details] ADD  CONSTRAINT [DF__ORDER DETAILS_DISCOUNT] DEFAULT (0) FOR [Discount]
if not exists(select * from sysobjects where name = 'DF__ORDER DETAILS_QUANTITY' and xtype = 'D')
ALTER TABLE [Order Details] ADD  CONSTRAINT [DF__ORDER DETAILS_QUANTITY] DEFAULT (1) FOR [Quantity]
if not exists(select * from sysobjects where name = 'DF__ORDER DETAILS_UNITPRICE' and xtype = 'D')
ALTER TABLE [Order Details] ADD  CONSTRAINT [DF__ORDER DETAILS_UNITPRICE] DEFAULT (0) FOR [UnitPrice]
GO

--DEFAULTS FOR TABLE [Orders]
if not exists(select * from sysobjects where name = 'DF__ORDERS_FREIGHT' and xtype = 'D')
ALTER TABLE [Orders] ADD  CONSTRAINT [DF__ORDERS_FREIGHT] DEFAULT (0) FOR [Freight]
GO

--DEFAULTS FOR TABLE [Products]
if not exists(select * from sysobjects where name = 'DF__PRODUCTS_DISCONTINUED' and xtype = 'D')
ALTER TABLE [Products] ADD  CONSTRAINT [DF__PRODUCTS_DISCONTINUED] DEFAULT (0) FOR [Discontinued]
if not exists(select * from sysobjects where name = 'DF__PRODUCTS_REORDERLEVEL' and xtype = 'D')
ALTER TABLE [Products] ADD  CONSTRAINT [DF__PRODUCTS_REORDERLEVEL] DEFAULT (0) FOR [ReorderLevel]
if not exists(select * from sysobjects where name = 'DF__PRODUCTS_UNITPRICE' and xtype = 'D')
ALTER TABLE [Products] ADD  CONSTRAINT [DF__PRODUCTS_UNITPRICE] DEFAULT (0) FOR [UnitPrice]
if not exists(select * from sysobjects where name = 'DF__PRODUCTS_UNITSINSTOCK' and xtype = 'D')
ALTER TABLE [Products] ADD  CONSTRAINT [DF__PRODUCTS_UNITSINSTOCK] DEFAULT (0) FOR [UnitsInStock]
if not exists(select * from sysobjects where name = 'DF__PRODUCTS_UNITSONORDER' and xtype = 'D')
ALTER TABLE [Products] ADD  CONSTRAINT [DF__PRODUCTS_UNITSONORDER] DEFAULT (0) FOR [UnitsOnOrder]
GO

--DROP ANY AUDIT TRIGGERS FOR [Categories]
if exists(select * from sysobjects where name = '__TR_Categories__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Categories__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Categories__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Categories__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Categories__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Categories__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [CustomerCustomerDemo]
if exists(select * from sysobjects where name = '__TR_CustomerCustomerDemo__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_CustomerCustomerDemo__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_CustomerCustomerDemo__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_CustomerCustomerDemo__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_CustomerCustomerDemo__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_CustomerCustomerDemo__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [CustomerDemographics]
if exists(select * from sysobjects where name = '__TR_CustomerDemographics__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_CustomerDemographics__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_CustomerDemographics__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_CustomerDemographics__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_CustomerDemographics__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_CustomerDemographics__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Customers]
if exists(select * from sysobjects where name = '__TR_Customers__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Customers__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Customers__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Customers__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Customers__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Customers__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Employees]
if exists(select * from sysobjects where name = '__TR_Employees__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Employees__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Employees__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Employees__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Employees__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Employees__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [EmployeeTerritories]
if exists(select * from sysobjects where name = '__TR_EmployeeTerritories__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_EmployeeTerritories__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_EmployeeTerritories__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_EmployeeTerritories__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_EmployeeTerritories__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_EmployeeTerritories__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Order Details]
if exists(select * from sysobjects where name = '__TR_Order Details__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Order Details__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Order Details__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Order Details__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Order Details__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Order Details__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Orders]
if exists(select * from sysobjects where name = '__TR_Orders__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Orders__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Orders__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Orders__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Orders__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Orders__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Products]
if exists(select * from sysobjects where name = '__TR_Products__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Products__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Products__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Products__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Products__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Products__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Region]
if exists(select * from sysobjects where name = '__TR_Region__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Region__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Region__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Region__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Region__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Region__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Shippers]
if exists(select * from sysobjects where name = '__TR_Shippers__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Shippers__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Shippers__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Shippers__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Shippers__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Shippers__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Suppliers]
if exists(select * from sysobjects where name = '__TR_Suppliers__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Suppliers__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Suppliers__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Suppliers__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Suppliers__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Suppliers__DELETE]
GO

--DROP ANY AUDIT TRIGGERS FOR [Territories]
if exists(select * from sysobjects where name = '__TR_Territories__INSERT' AND xtype = 'TR')
DROP TRIGGER [__TR_Territories__INSERT]
GO
if exists(select * from sysobjects where name = '__TR_Territories__UPDATE' AND xtype = 'TR')
DROP TRIGGER [__TR_Territories__UPDATE]
GO
if exists(select * from sysobjects where name = '__TR_Territories__DELETE' AND xtype = 'TR')
DROP TRIGGER [__TR_Territories__DELETE]
GO

